package cn.tips.dmp.common.sms.captcha.service.impl;

import cn.tips.dmp.common.sms.captcha.service.CaptchaService;
import cn.tips.dmp.supports.helper.Md5PasswordHelper;
import cn.tips.dmp.supports.util.IpUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpServletRequest;

/**
 * SmsOperationImpl
 *
 */
@Service
@Slf4j
public class CaptchaServiceImpl implements CaptchaService {

    @Autowired
    private Md5PasswordHelper md5PasswordHelper;

    @Override
    public String getImgCaptchaKey(HttpServletRequest request){
        String ipAddr = IpUtil.getIpAddr(request);
        // 请求头
        String userAgent=request.getHeader("user-Agent");
        return "user-service:captcha:" + md5PasswordHelper.md5Encrypt(ipAddr+userAgent);
    }
}
